﻿function dyniframesize(down) {
	$("#"+down).css("height", "auto").height($(window.frames[down].document).height());
}
function initHiddenIpt(){
	var umap = parseurl();
	if(umap != null){
		$('#czryName').val(umap['czryName']);
		$('#czryUuid').val(umap['czryUuid']);
		$('#swjgUuid').val(umap['swjgUuid']);
		$('#swjgName').val(umap['swjgName']);
		$('#menuUuid').val(umap['menuUuid']);
		$('#menuName').val(umap['menuName']);
		$('#childMenuUuid').val(umap['childMenuUuid']);
		$('#childMenuName').val(umap['childMenuName']);
		$('#formXgrq').val(showLocale(new Date(),4));
	}
}

function toDX(n) { //金额大写转换函数
	if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
	return "数据非法";
	var unit = "仟佰拾亿仟佰拾万仟佰拾元角分", str = "";
	n += "00";
	var p = n.indexOf('.');
	if (p >= 0)
	n = n.substring(0, p) + n.substr(p+1, 2);
	unit = unit.substr(unit.length - n.length);
	for (var i=0; i < n.length; i++)
	str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i);
	return str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(壹拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
};

function parseurl(){
	var urlparam = window.location.search.substr(1);
	var up = urlparam.split('&');
	var umap = {};
	for(var i in up)
		umap[up[i].split('=')[0]] = up[i].split('=')[1];
	if(up.length > 1)
		return umap;
	return null;
}

function showLocale(objD,type){
	var str,colorhead,colorfoot;   
	var yy = objD.getYear();   
	if(yy<1900)
		yy = yy+1900;   
	var MM = objD.getMonth()+1;   
	var dd = objD.getDate();   
	var hh = objD.getHours();   
	if(hh<10) 
		hh = '0' + hh;   
	var mm = objD.getMinutes();   
	if(mm<10) 
		mm = '0' + mm;   
	var ss = objD.getSeconds();   
	if(ss<10) 
		ss = '0' + ss;   
	var ww = objD.getDay();   
	if ( ww==0 ) colorhead="<font color=\"#FF0000\">";   
	if ( ww > 0 && ww < 6 ) colorhead="<font color=\"#373737\">";   
	if ( ww==6 ) colorhead="<font color=\"#008000\">";   
	if (ww==0) ww="星期日";   
	if (ww==1) ww="星期一";   
	if (ww==2) ww="星期二";   
	if (ww==3) ww="星期三";   
	if (ww==4) ww="星期四";   
	if (ww==5) ww="星期五";   
	if (ww==6) ww="星期六";  
	colorfoot="</font>";
	if(type==1)//2012年1月1日+星期格式
		str = colorhead + yy + "年" + MM + "月" + dd + "日 " + " " + ww + colorfoot;
	else if(type==2)//2012-1-1
		str = yy + "-" + MM + "-" + dd;
	else if(type==3)//2012年1月1日1时1分1秒+星期格式
		str = colorhead + yy + "年" + MM + "月" + dd + "日 " + hh + ":" + mm + ":" + ss + " " + ww + colorfoot;
	else if(type==4)//2012-1-1-1 1:1:1
		str = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
	return(str);   
} 

function showShortLocale(objD){   
	var str,colorhead,colorfoot;   
	var yy = objD.getYear();   
	if(yy<1900)
		yy = yy+1900;   
	var MM = objD.getMonth()+1;   
	var dd = objD.getDate();   
	var hh = objD.getHours();   
	var ww = objD.getDay();   
	if ( ww==0 ) colorhead="<font color=\"#FF0000\">";   
	if ( ww > 0 && ww < 6 ) colorhead="<font color=\"#373737\">";   
	if ( ww==6 ) colorhead="<font color=\"#008000\">";   
	if (ww==0) ww="星期日";   
	if (ww==1) ww="星期一";   
	if (ww==2) ww="星期二";   
	if (ww==3) ww="星期三";   
	if (ww==4) ww="星期四";   
	if (ww==5) ww="星期五";   
	if (ww==6) ww="星期六";   
	colorfoot="</font>"  
	str = colorhead + yy + "年" + MM + "月" + dd + "日" + " " + ww + colorfoot;   
	return(str);   
}

function tick(){   
	var today;   
	today = new Date();   
	$('#systime').text( showLocale(today));
	window.setTimeout("tick()", 1000);   
}   

function openFormPage(pagename,menuId){
	var currentPage = "";
    if(pagename == '12366zsk'){
    	if(menuId == 'ssfg'){
    		currentPage = "http://93.16.16.206/wzgl/wz/chnlmodel.do?classid=31";
    	}else if(menuId == 'swgb'){
    		currentPage = "http://93.16.16.206/wzgl/wz/chnlmodel.do?classid=32";
    	}else if(menuId == 'zcjd'){
    		currentPage = "http://93.16.16.206/wzgl/wz/chnlmodel.do?classid=33";
    	}
    }else if(pagename == 'dzdak'){
    	if(menuId == 'jbzl_swdjz'){
    		parent.mainFrame.window.dzdak.colname = 'SWDJZ';parent.mainFrame.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_yyzz'){
    		parent.mainFrame.window.dzdak.colname = 'YYZZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_zzjgdmz'){
    		parent.mainFrame.window.dzdak.colname = 'ZZJGDMZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_frdmz'){
    		parent.mainFrame.window.dzdak.colname = 'FRDMZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_ybnsrzgz'){
    		parent.mainFrame.window.dzdak.colname = 'YBNSRZGZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_fpzgz'){
    		parent.mainFrame.window.dzdak.colname = 'FPZGZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_frsfz'){
    		parent.mainFrame.window.dzdak.colname = 'FRSFZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_bsrysfz'){
    		parent.mainFrame.window.dzdak.colname = 'BSRYSFZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_cwrysfz'){
    		parent.mainFrame.window.dzdak.colname = 'CWRYSFZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_cwrykjz'){
    		parent.mainFrame.window.dzdak.colname = 'CWRYKJZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_yhzhzm'){
    		parent.mainFrame.window.dzdak.colname = 'YHZHZM';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'jbzl_scjydzzm'){
    		parent.mainFrame.window.dzdak.colname = 'SCJYDZZM';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'xyzl_htzm'){
    		parent.mainFrame.window.dzdak.colname = 'HTZM';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}else if(menuId == 'xyzl_zczm'){
    		parent.mainFrame.window.dzdak.colname = 'ZCZM';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}else if(menuId == 'xyzl_xyszm'){
    		parent.mainFrame.window.dzdak.colname = 'XYSZM';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}else if(menuId == 'yhzm_xgz'){
    		parent.mainFrame.window.dzdak.colname = 'XGZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'yhzm_cjz'){
    		parent.mainFrame.window.dzdak.colname = 'CJZ';parent.mainFrame.window.dzdak.width = 800;parent.mainFrame.window.dzdak.height = 600;
    	}else if(menuId == 'yhzm_qtyhzm'){
    		parent.mainFrame.window.dzdak.colname = 'QTYHZM';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}else if(menuId == 'qtzmzl_ckjyqpzws'){
    		parent.mainFrame.window.dzdak.colname = 'CKJYQPZWS';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}else if(menuId == 'qtzmzl_fdjgyzbg'){
    		parent.mainFrame.window.dzdak.colname = 'FDJGYZBG';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}else if(menuId == 'qtzmzl_qtzm'){
    		parent.mainFrame.window.dzdak.colname = 'QTZM';parent.mainFrame.window.dzdak.width = 600;parent.mainFrame.window.dzdak.height = 800;
    	}
    	dzdak.getImage();
    }else if(pagename == 'reportcenter'){
    	if(menuId == 'sswszlsl'){
    		currentPage = "reportpage/reportMain.html";
    	}else if(menuId == 'aywfswjgdb'){
    		currentPage = "reportpage/formSwjgMain.html";
    	}else if(menuId == 'aywfsjdtj'){
    		currentPage = "reportpage/reportMain.html";
    	}else if(menuId == 'aywfswrytj'){
    		currentPage = "reportpage/reportMain.html";
    	}else if(menuId == 'bzdsslmxcx'){
    		currentPage = "reportpage/formDetalMain.html";
    	}
    }else if(pagename == 'sysset'){
    	if(menuId == 'swjgsz'){
    		currentPage = "syssetpage/swjg_settings.html";
    	}else if(menuId == 'jsgnsz'){
    		currentPage = "syssetpage/jsgnsz.html";
    	}else if(menuId == 'bzdssz'){
    		currentPage = "syssetpage/bdzs_setter.html";
    	}else if(menuId == 'bzdsqx'){
    		currentPage = "syssetpage/bzdsqx.html";
    	}else if(menuId == 'swrysz'){
    		currentPage = "syssetpage/swry_setter.html";
    	}else if(menuId == 'modifyPassword'){
    		currentPage = "syssetpage/modifyPassword.html";
    	}
    }
    $("#mainFrame",parent.document.body).attr("src",currentPage); 
}

//菜单级联
//获得大类菜单
function getMenuList(){
	$.ajax({
		type: "GET",
        url: config.baseURL + "menu/getMenuList.action",
        cache:false,
        dataType: "json",
        data : {
			"menu.id":1
        },
        success: function(data){
        	if(data.result.success==true){
        		$.each(data.list, function(index, menu) {
        			 var opt = $("<option/>").text(menu[1]).attr("value", menu[0]); 
        			 $("#menu").append(opt);
        			 if(index == 0)
        				 getChildMenu(menu[0]);
        		});
        		$("#menu").change(function(){ 
        			getChildMenu($(this).val());
				});
        	}
        },
        error:function(){
        	alert('获取业务类型出错!');
        }
	});
}

//获得子菜单
function getChildMenu(menuId){
	$.ajax({
		type: "GET",
        url: config.baseURL + "menu/getMenuList.action",
        cache:false,
        dataType: "json",
        data : {
			"menu.id":menuId
        },
        success: function(data){
        	$("#childMenu").empty(); 
        	$.each(data.list, function(index, menu) {
    			var opt = $("<option/>").text(menu[1]).attr("value", menu[0]).attr('title',menu[1]); 
    			$("#childMenu").append(opt);   
    		});
        },
        error:function(){
        	alert('获取小类业务类型出错!');
        }
	});
}
